home *** CD-ROM | disk | FTP | other *** search
/ Tux Racer / Tux Racer.iso / program files / Sunspire Studios / Tux Racer / tcllib / saveheights.tcl < prev    next >
Encoding:
Text File  |  2001-05-03  |  977 b   |  49 lines

  1.  
  2. namespace eval TRSaveHeights {
  3.     variable savedHeights
  4.  
  5.     proc Save { node } {
  6.     variable savedHeights
  7.  
  8.     if { ![objcall $node is_a s_sgnode] } {
  9.         error "$node is not an s_sgnode"
  10.     }
  11.  
  12.     if [info exists savedHeights] {
  13.         unset savedHeights
  14.     }
  15.  
  16.     SaveAux $node 
  17.     }
  18.  
  19.     proc SaveAux { node } {
  20.     variable savedHeights
  21.  
  22.     foreach child [objget $node children] {
  23.         if { [objcall $child is_a s_sgnode] } {
  24.         if { ![objget $child world_matrix_is_identity] || \
  25.             [objget $child class] != ":classes:s_sgnode" } {
  26.             set savedHeights($child) \
  27.                 [objget $child height_above_terrain]
  28.         } else {
  29.             SaveAux $child
  30.         }
  31.         }
  32.     }
  33.     }
  34.  
  35.     proc Restore { } {
  36.     variable savedHeights
  37.  
  38.     foreach node [array names savedHeights] {
  39.         if { ![objexists $node] } {
  40.         continue
  41.         }
  42.         if { ![objcall $node is_a s_sgnode] } {
  43.         continue
  44.         }
  45.         objcall $node set_height_above_terrain $savedHeights($node)
  46.     }
  47.     }
  48. }
  49.